package com.starry.home.viewmodel.main

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.switchMap
import com.starry.home.logic.model.login.UserInfoBean
import com.starry.home.logic.network.Repository
import com.starry.core.viewmodel.BaseViewModel

/**
 * Package:com.starry.dotpen_patients.viewmodel.main
 * Author:starr
 * Time:2024/1/30 19:36
 * Description: 完善用户信息界面
 */
class UserInfoViewModel : BaseViewModel() {

    private val _userIdLiveData = MutableLiveData<Int>()
    val userInfo = _userIdLiveData.switchMap { userId -> Repository.getUserInfo(userId) }
    fun getUserInfo(userId: Int){
        _userIdLiveData.value = userId
    }


    private val _userInfoLiveData = MutableLiveData<UserInfoBean>()
    val responseBean = _userInfoLiveData.switchMap { userInfo -> Repository.updateUserInfo(userInfo) }
    fun updateUserInfo(userInfo: UserInfoBean) {
        _userInfoLiveData.value = userInfo
    }
}